﻿namespace metro_wpf.Views.Component
{
    using MahApps.Metro.Controls;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;

    /// <summary>
    /// SVNAddTemplate.xaml 的交互逻辑
    /// </summary>
    public partial class SVNAddTemplate : UserControl
    {
        public SVNAddTemplate()
        {
            InitializeComponent();
            /** TwoWay
             * System.Windows.Markup.XamlParseException
              HResult=0x80131501
              Message=“设置属性“System.Windows.Controls.Primitives.ButtonBase.Command”时引发了异常。”，行号为“59”，行位置为“21”。
              Source=PresentationFramework
              StackTrace:
               at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
               at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
               at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
               at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
               at OperationTools.Views.Component.SVNAddTemplate.InitializeComponent() in D:\JuleProject\workspace\tools\C#\OperationTools\OperationTools\Views\Component\SVNAddTemplate.xaml:line 1

            内部异常 1:
            InvalidOperationException: 无法对“OperationTools.ViewModel.SVNAddTemplateViewModel”类型的只读属性“ChildDialog”进行 TwoWay 或 OneWayToSource 绑定。

             **/
        }

        /// <summary>
        /// Cancel Click事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddTemplateCancel_Click(object sender, RoutedEventArgs e)
        {
            //如果数据没保存 则先保存
            Window mainWindow = Window.GetWindow(this);
            object addTemplateFlyout = mainWindow.FindName("AddTemplateFlyout");
            Flyout flyout = addTemplateFlyout as Flyout;
            flyout.IsOpen = !flyout.IsOpen;
        }

        private void AddTemplateOk_Click(object sender, RoutedEventArgs e)
        {
            Tile tile = new Tile();
            SVNProjectView svnProjectView = new SVNProjectView();
            Random random = new Random();
            tile.Title = "Game";
            tile.Count = "Game";
            tile.HorizontalTitleAlignment = HorizontalAlignment.Right;
            tile.Style = (Style)svnProjectView.FindResource("LargeTileStyle");
            tile.Margin = new Thickness(3);
            tile.Background = new SolidColorBrush(Colors.Teal);
            svnProjectView.wrapPanel.Children.Add(tile);
        }
    }
}
